package com.ckmod.zyr3x.tools.components;

import android.view.View;
import android.widget.*;

/**
 * Created by IntelliJ IDEA.
 * User: zyr3x
 * Date: 12.07.11
 * Time: 10:24
 * To change this template use File | Settings | File Templates.
 */
public class ComplexCheckedBilder implements android.widget.SimpleAdapter.ViewBinder {
               public boolean setViewValue(View view, Object data, String textRepresentation) {
                        if( (view instanceof CheckedTextView))
                        {
                            String[] dataItem = textRepresentation.split(":");
                            if(dataItem.length > 1){
                                boolean checked = CSSConfig.getValue(dataItem[1]).equals("1");
                               ((CheckedTextView) view).setChecked(checked);
                               ((CheckedTextView) view).setText(dataItem[0]);
                            }
                            else
                               ((CheckedTextView) view).setText(dataItem[0]);

                        }
                        else
                        {
                            if((view instanceof TextView))
                            {
                              ((TextView) view).setText(textRepresentation);
                            }
                        }
                        return true;

                }

    }
